import axios from "axios";

export const getTrucksList = (callback) => {
    axios.get('/truck').then((response) => {
        callback(response.data);
    });
}

export const getTruck = (id, callback) => {
    axios.get('/truck/' + id).then((response) => {
        callback(response.data)
    })
}

export const deleteTruck = (id, callback) => {
    axios.delete('/truck/' + id).then((response) => {
        callback(response.data);
    });
}

export const updateTruck = (truckData, callback) => {
    axios.put('/truck/' + truckData.tid, truckData).then((response) => {
        callback(response.data ? 1 : 0);
    })
}


export const createTruck = (truckData, callback) => {
    axios.post('/truck', truckData).then((response) => {
        callback(response.data ? 1 : 0)
    })
}

export const findIdByNum = (num, callback) => {
    axios.get('/truck/id/' + num).then((response) => {
        callback(response.data);
    })
}

export const truckCheckOut = (form, callback) => {
    axios.post('/truck/checkout', null, {params: form}).then((response) => {
        callback(response.data ? 1 : 0)
    })
}